<?php
namespace app\user\validate\user;

use think\Validate;

/**
 * 用户验证
 */
class Balance extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'type'          => 'require|in:increase,decrease',
        'num'           => 'require|float',
        'payway'        => 'require|in:alipay,wxpay,payapl',
        'recharge_id'   => 'require|integer',
        'payment'       => 'require|float',
        'balance'       => 'require|float',
        'phone'         => 'require|mobile',
        'code'          => 'require|integer',
        'password'      => 'require|max:32',
        'verify_type'   => 'require|in:1,2',
        'original_pwd'  => 'require|max:32',
    ];

    protected $field = [
        'type'          => '变更方式',
        'num'           => '变更数额',
        'payway'        => '支付方式',
        // 'recharge_id'   => '充值方式',
        'payment'       => '支付金额',
        'balance'       => '充值金额',
        'phone'         => '手机号',
        'code'          => '验证码',
        'password'      => '密码',
        'verify_type'   => '验证方式',
        'original_pwd'  => '原密码',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'update'                => ['type', 'num'],
        'recharge_order'        => ['recharge_id'], // ,'payment','balance'
        'recharge_pay'          => ['payway', 'order_no'],
        'pwd_verify'            => ['phone', 'code'],
        'pwd_before'            => ['password'],
        'pwd_set_phone'         => ['password'],
        'pwd_set_default'       => ['password', 'phone', 'code'],
        'pwd_update_app'        => ['password'],
        'pwd_update_original'   => ['password', 'original_pwd'],
        'pwd_update_phone'      => ['password', 'phone', 'code'],
    ];

}
